package com.hjm.project.team.detailed.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.team.detailed.domain.TeamYlDetailed;
import com.hjm.project.team.detailed.service.ITeamYlDetailedService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 引流相关奖励明细Controller
 * 
 * @author maker-platform
 * @date 2021-04-15
 */
@Controller
@RequestMapping("/detailed/detailed")
public class TeamYlDetailedController extends BaseController
{
    private String prefix = "team/detailed";

    @Resource
    private ITeamYlDetailedService teamYlDetailedService;

    @RequiresPermissions("detailed:detailed:view")
    @GetMapping()
    public String detailed() {
        return prefix + "/detailed";
    }

    /**
     * 查询引流相关奖励明细列表
     */
    @RequiresPermissions("detailed:detailed:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TeamYlDetailed teamYlDetailed)
    {
        startPage();
        List<TeamYlDetailed> list = teamYlDetailedService.selectTeamYlDetailedList(teamYlDetailed);
        return getDataTable(list);
    }

    /**
     * 导出引流相关奖励明细列表
     */
    @RequiresPermissions("detailed:detailed:export")
    @Log(title = "引流相关奖励明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TeamYlDetailed teamYlDetailed)
    {
        List<TeamYlDetailed> list = teamYlDetailedService.selectTeamYlDetailedList(teamYlDetailed);
        ExcelUtil<TeamYlDetailed> util = new ExcelUtil<TeamYlDetailed>(TeamYlDetailed.class);
        return util.exportExcel(list, "detailed");
    }

    /**
     * 新增引流相关奖励明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存引流相关奖励明细
     */
    @RequiresPermissions("detailed:detailed:add")
    @Log(title = "引流相关奖励明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TeamYlDetailed teamYlDetailed)
    {
        return toAjax(teamYlDetailedService.insertTeamYlDetailed(teamYlDetailed));
    }

    /**
     * 修改引流相关奖励明细
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        TeamYlDetailed teamYlDetailed = teamYlDetailedService.selectTeamYlDetailedById(id);
        mmap.put("teamYlDetailed", teamYlDetailed);
        return prefix + "/edit";
    }

    /**
     * 修改保存引流相关奖励明细
     */
    @RequiresPermissions("detailed:detailed:edit")
    @Log(title = "引流相关奖励明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TeamYlDetailed teamYlDetailed)
    {
        return toAjax(teamYlDetailedService.updateTeamYlDetailed(teamYlDetailed));
    }

    /**
     * 删除引流相关奖励明细
     */
    @RequiresPermissions("detailed:detailed:remove")
    @Log(title = "引流相关奖励明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(teamYlDetailedService.deleteTeamYlDetailedByIds(ids));
    }
}
